import axiosInstance from './axios'
export interface ApiResult<T> {
  code: number
  message: string
  data: any,
  token?:string,
  total?:number
}
export async function get<T>(url: string, params?: any): Promise<ApiResult<T>|any> {
  const {data} = await axiosInstance.get<ApiResult<T>>(url, { params })
  return data
}
export async function post<T>(url: string, data?: any): Promise<ApiResult<T>> {
  const { data:res } = await axiosInstance.post<ApiResult<T>>(url, data)
  return res
}
export async function put<T>(url: string, data?: any): Promise<ApiResult<T>> {
  const {data:res} = await axiosInstance.put<ApiResult<T>>(url, data)
  return res
}
export async function del<T>(url: string, params?: any): Promise<ApiResult<T>> {
  const { data } = await axiosInstance.delete<ApiResult<T>>(url, { params })
  return data
}
